home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume4 / tvx / part04 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  44.5 KB

  1. From: gatech!unmvax!wampler (Bruce Wampler)
  2. Subject: tvx: 4 of 10
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 4, Issue 18
  7. Submitted by: gatech!unmvax!wampler (Bruce Wampler)
  8.  
  9. #--------CUT---------CUT---------CUT---------CUT--------#
  10. #########################################################
  11. #                                                       #
  12. # This is a shell archive file.  To extract files:      #
  13. #                                                       #
  14. #    1)    Make a directory (like tvx) for the files.      #
  15. #    2) Write a file, such as "filen.shar", containing  #
  16. #       this archive file into the directory.           #
  17. #    3) Type "sh file.shar".  Do not use csh.           #
  18. #                                                       #
  19. #########################################################
  20. #
  21. #
  22. echo Extracting tvx_1.c:
  23. sed 's/^X//' >tvx_1.c <<\SHAR_EOF
  24. X/* ========================================================================
  25. X
  26. X    TVX - A full screen editor in C
  27. X
  28. XOriginally developed by:
  29. X
  30. X    Dr. Bruce E. Wampler
  31. X    University of New Mexico
  32. X    Department of Computer Science
  33. X    Farris Engineering Center
  34. X    Albuquerque, NM 87131
  35. X
  36. X    UUCP: ...{ucbvax | ihnp4!lanl | seismo!gatech}!unmvax!wampler
  37. X
  38. X
  39. X   This version of TVX Copyright (c) 1986 by Bruce E. Wampler
  40. X
  41. X   Permission is hereby granted for free, unrestricted nonprofit
  42. X   use of this software.  Please feel free to modify, distribute,
  43. X   and share this software as long as you aren't making any money
  44. X   from it.  If you want to use this code in a profit making environment,
  45. X   please contact the author for permission.
  46. X
  47. X
  48. X    Direct comments, bug reports, suggestions to
  49. X    Bruce Wampler at above address.
  50. X
  51. XConverted from Ratfor to C January 1981 (note: since the editor
  52. X    was originally in Ratfor, there are certain remnants of the
  53. X    original structure left over.  There are a lot of things that
  54. X    could have been done better if written in C originally.
  55. X    So it goes.
  56. X
  57. XPLEASE! If you are making additional modifications, use the
  58. X    indentation scheme used here (line up {,}'s!!!) instead
  59. X    of the unmaintainable indentation used by K&R!.
  60. X    Also, please mark your changes with initials and date!
  61. X    If possible, put your changes in #ifdefs so they can be
  62. X    incorporated into the master source easily if appropriate.
  63. X
  64. XDescription of files required: (names lower case on unix)
  65. X
  66. X    TVX_1.C       - main part of code (part 1), mostly os/terminal independent
  67. X    TVX_2.C       - main part of code (part 2), mostly os/terminal independent
  68. X    TVX_EDIT.C - all emulator version dependent code here.
  69. X    TVX_LEX.C  - defaults, some os dependent stuff in here.  Major
  70. X             changes in defaults can be fixed by recompiling this file.
  71. X    TVX_IO.C   - almost all I/O, including screen, confined to this file.
  72. X    TVX_LIB.C  - misc library routines needed by TVX.
  73. X    TVX_IBM.C  - IBM-PC specific code, specifically the screen driver
  74. X      (TVX_IBM.ASM - hand optimized version of TVX_IBM.C)
  75. X    TVX_UNIX.C - contains unix specific code, including termcap driver
  76. X    TVX_CFG.C  - used to build CONFIG.TVX file for -c switch
  77. X    TVX_PTCH.C - used to permanently patch tvx with config file
  78. X
  79. X    TVX_DEFS.IC - #define's for version, os, terminal, defaults
  80. X    TVX_GLBL.IC - global data structures
  81. X    TVX_TERM.IC - definitions for various terminals and systems
  82. X
  83. X    Most distributions will contain other useful files as well.
  84. X
  85. X============================================================================ */
  86. X
  87. X#include "tvx_defs.ic"        /* note tv_defs.ic will #include stdio.h */
  88. X#include "tvx_glbl.ic"
  89. X
  90. X  char clower(),cupper();
  91. X
  92. X/* =============================>>> MAIN <<<============================= */
  93. X  main (argc,argv)
  94. X  int argc;
  95. X  char *argv[];
  96. X  {
  97. X
  98. X    checkos();        /* check operating system version */
  99. X    force_tty = FALSE;    /* won't usually force tty mode */
  100. X
  101. X    tvinit();
  102. X    ttinit();        /* initialize tt: */
  103. X    trmini();        /* init terminal if needed */
  104. X    csrcmd();        /* make cursor command cursor */
  105. X
  106. X    fopenx(argc,argv);    /* open the file, maybe change switches */
  107. X
  108. X    tvidefs();        /* set defaults */
  109. X    opnbak();        /* may or may not be null routine */
  110. X
  111. X    edit();        /* edit the file */
  112. X
  113. X    clobak();        /* may be null routine */
  114. X
  115. X    file_exit();    /* clean up files */
  116. X
  117. X    ttymode = FALSE;
  118. X
  119. X    if (*dest_file)
  120. X    remark(dest_file);    /* echo final file name */
  121. X    else
  122. X      {
  123. X    prompt("R/O, no changes: ") ; remark(orig_file);
  124. X      }
  125. X
  126. X    reset();        /* reset anything necessary */
  127. X    quit();
  128. X  }
  129. X
  130. X/* =============================>>> ASK <<<============================= */
  131. X  ask(msg,rply,rcnt)
  132. X  char *msg,*rply;
  133. X  int rcnt;
  134. X  {            /* get a reply, via tty if necessary */
  135. X    int oldtty;
  136. X
  137. X    oldtty = ttymode;
  138. X    ttymode = FALSE;    /* force echo on */
  139. X    prompt(msg);
  140. X    reply(rply,rcnt);
  141. X    ttymode = oldtty;    /* back how it was */
  142. X  }
  143. X
  144. X/* =============================>>> BEGLIN <<<============================= */
  145. X  beglin()
  146. X  {  /* beglin - move cursor to beginning of current line */
  147. X
  148. X    SLOW int xf;
  149. X
  150. X    curchr = *(lines+curlin) + 1;    /* point to current character */
  151. X    xf = findx();    /* this line needed to make the next */
  152. X            /* call eval order independent, if you wondered */
  153. X    tvxy(xf,tvy);    /* and move cursor */
  154. X#ifdef SCR_BUF
  155. X    ttflush();
  156. X#endif
  157. X  }
  158. X
  159. X/* =============================>>> BOTPAG <<<============================= */
  160. X  botpag()
  161. X  { /* botpag - move cursor to bottom of current page (buffer) */
  162. X
  163. X    curlin = nxtlin-1;        /* the last real line of text */
  164. X    curchr = *(lines+curlin) + 1; /* the first char of that line */
  165. X    endlin();            /* goto end of the line */
  166. X    newscr();            /* update the screen */
  167. X  }
  168. X
  169. X/* ============================>>> CHK_RPT_NR <<<============================ */
  170. X  chk_rpt_nr(val)
  171. X  int val;
  172. X  {        /* see if val is in valid range */
  173. X
  174. X    if (val <= 0 || val > REPEATBUFS)    /* out of range */
  175. X      {
  176. X    tverrb("Bad rpt buff # ");
  177. X    return (FALSE);
  178. X      }
  179. X    else
  180. X    return (TRUE);
  181. X  }
  182. X
  183. X/* =============================>>> CMDERR <<<============================= */
  184. X  cmderr(chr)
  185. X  char chr;
  186. X  {    /* cmderr - invalid command entered */
  187. X
  188. X    static char badcmd[] = "Bad command:   ";
  189. X
  190. X    if (chr >= ' ')
  191. X      {
  192. X    badcmd[13] = chr;     /* stick in after : */
  193. X    badcmd[14] = ' ';
  194. X      }
  195. X    else
  196. X      {
  197. X    badcmd[13] = '^';
  198. X    badcmd[14] = chr + '@';
  199. X      }
  200. X    tverrb(badcmd);
  201. X  }
  202. X
  203. X/* =============================>>> COMBIN <<<============================= */
  204. X  combin()
  205. X  { /* combin - combine current line with next line
  206. X        update screen -    cursor assumed to be on curlin */
  207. X
  208. X    SLOW int to,from,xf;
  209. X    SLOW BUFFINDEX newl,k1,k2;
  210. X
  211. X    if (curlin+1 >= nxtlin)        /* can't combine */
  212. X    return (FALSE);
  213. X    if (nxtsav-nxtchr < ALMOSTOUT)    /* check if need g.c. */
  214. X    if (! gbgcol())
  215. X        return (FALSE);
  216. X    newl = nxtchr;            /* where next char goes */
  217. X    stcopy(buff,*(lines+curlin),buff,&nxtchr); /* copy over current line */
  218. X    curchr = nxtchr;            /* update the curchr */
  219. X    k1 = *(lines+curlin);          /* we will kill this line */
  220. X    *(lines+curlin) = newl;        /* remember where it is */
  221. X    stcopy(buff,*(lines+curlin+1)+1,buff,&nxtchr); /* append the next line */
  222. X    ++nxtchr;                /* fix nxtchr */
  223. X    to = curlin+1;
  224. X    k2 = *(lines+to);            /* we will kill this line */
  225. X    for (from=curlin+2; from < nxtlin ; )    /* copy line to end */
  226. X      {
  227. X    *(lines+to++) = *(lines+from++);
  228. X      }
  229. X    --nxtlin;        /* update line ptr */
  230. X    kline(k1);        /* kill the old lines now */
  231. X    kline(k2);
  232. X    if (tvdlin <= dsplin)    /* not at end of buffer */
  233. X      {
  234. X    tvescr();        /* erase rest of screen */
  235. X    tvxy(1,tvy);    /* fix it up */
  236. X    tvtype(curlin,min(tvlins-tvdlin+1,nxtlin-curlin));
  237. X      }
  238. X    else            /* at end of buffer */
  239. X    newscr();
  240. X
  241. X    xf = findx();
  242. X    tvxy(xf,tvy); /* home cursor */
  243. X#ifdef SCR_BUF
  244. X    ttflush();
  245. X#endif
  246. X    return (TRUE);
  247. X  }
  248. X
  249. X/* =============================>>> CTRLCH <<<============================= */
  250. X  ctrlch(chr)
  251. X  char chr;
  252. X  { /* ctrlch - echoes a control character for search and lex */
  253. X
  254. X    if (chr >= ' ')
  255. X    tvcout(chr);    /* echo as is */
  256. X    else if (chr == CR)        /* carriage return may be special */
  257. X      {
  258. X    tvcout(CR);
  259. X#ifdef USELF
  260. X    tvcout(LF);    /*$$$ some machines need LF */
  261. X    if (dsp_mem)
  262. X        tvelin();
  263. X#endif
  264. X      }
  265. X    else if (chr == ESC)    /* escape as $ */
  266. X    tvcout('$');
  267. X    else            /* echo most chars as '^x' */
  268. X      {
  269. X    tvcout('^');
  270. X    tvcout(chr+'@');
  271. X      }
  272. X#ifdef SCR_BUF
  273. X    ttflush();
  274. X#endif
  275. X  }
  276. X
  277. X/* =============================>>> DELNXT <<<============================= */
  278. X  int delnxt(cnt)
  279. X  int cnt;
  280. X  {  /* delnxt - delete next n characters  */
  281. X
  282. X    static char chdel;
  283. X    SLOW int abscnt,newx;
  284. X    SLOW BUFFINDEX to;
  285. X    SLOW char ans[2];
  286. X    FAST int i;
  287. X
  288. X    abscnt = (cnt > 0) ? cnt : (-cnt);    /* remember absolute value of cnt */
  289. X    if (abscnt > 100)        /* make sure about this! */
  290. X      {                /* they probably meant kill lines! */
  291. X    tvclr();
  292. X    ask("Kill that many chars? (y/n) ",ans,1);
  293. X    verify(1);
  294. X    if (clower(ans[0]) != 'y')
  295. X        return (TRUE);
  296. X      }
  297. X
  298. X    if (cnt > 0)        /* deleting forewards */
  299. X      {
  300. X    chdel = *(buff+curchr); /* remember the char we are deleting */
  301. X    for (i=1; curlin < nxtlin && i <= cnt; ++i) /* don't pass end of buff */
  302. X      {
  303. X        if (*(buff+curchr)==ENDLINE)    /* combine when end of line */
  304. X          {
  305. X        if (! combin())
  306. X          {
  307. X            return (FALSE);
  308. X          }
  309. X          }
  310. X        else        /* deleting one character */
  311. X          {
  312. X        to=curchr;    /* overwrite current line */
  313. X        stcopy(buff,curchr+1,buff,&to); /* copy the rest of the line */
  314. X        for (++to; *(buff+to) != BEGLINE && to < nxtchr; ++to)
  315. X            *(buff+to) = GARBAGE; /* mark the garbage characters */
  316. X          }
  317. X      }
  318. X      }
  319. X    else if (cnt < 0)        /* deleting backwards */
  320. X      {
  321. X    abscnt=(-cnt);
  322. X    chdel = *(buff+curchr-1); /* remember the char we are deleting */
  323. X    for (i=cnt; curlin >= 1 && i<0; ++i)    /* don't go past start */
  324. X      {
  325. X        if (*(buff+curchr-1)==BEGLINE)    /* deleting line separator */
  326. X          {
  327. X        if (curlin > 1)     /* not past beginning */
  328. X          {
  329. X            dwnlin(-1);        /* go up one line */
  330. X            endlin();        /* get end of the line */
  331. X            if (!combin())    /* and combine */
  332. X              {
  333. X            return (FALSE);
  334. X              }
  335. X          }
  336. X          }
  337. X        else            /* killing a normal character */
  338. X          {
  339. X        to=curchr-1;        /* overwrite in place */
  340. X        stcopy(buff,curchr,buff,&to); /* copy the rest of the line */
  341. X        for (++to; *(buff+to) != BEGLINE && to < nxtchr; ++to)
  342. X            *(buff+to)=GARBAGE; /* mark the garbage characters */
  343. X        --curchr;
  344. X          }
  345. X      }
  346. X      }
  347. X    newx=findx();        /* where cursor will go */
  348. X    tvxy(newx,tvy);        /* reposition cursor */
  349. X    if (chdel >= ' ' && abscnt == 1 && cdelchr[0])
  350. X    sendcs(cdelchr);
  351. X    else
  352. X      {
  353. X    if (chdel < ' ' || abscnt != 1)
  354. X        tvelin();        /* erase rest of the line */
  355. X    else            /* need to check for tabs following */
  356. X      {
  357. X        for (i = curchr ; *(buff+i)!=ENDLINE ; ++i)
  358. X        if (*(buff+i) < ' ')
  359. X          {
  360. X            tvelin();    /* need to erase the line */
  361. X            break;
  362. X          }
  363. X      }
  364. X    tvtyln(curchr);        /* retype the rest */
  365. X    if (chdel >= ' ' && abscnt == 1 && last_col_out < tvcols)
  366. X    tvcout(' ');        /* "erase" last char on line */
  367. X    tvxy(newx,tvy);        /* restore the cursor */
  368. X      }
  369. X#ifdef SCR_BUF
  370. X    ttflush();
  371. X#endif
  372. X    return (TRUE);
  373. X  }
  374. X
  375. X/* =============================>>> DWNLIN <<<============================= */
  376. X  dwnlin(cnt)
  377. X  int cnt;
  378. X  { /* dwnlin - move dot down cnt lines */
  379. X
  380. X    SLOW int oldlin,change;
  381. X
  382. X    if (curlin==nxtlin-1 && cnt > 0)    /* down from last line? */
  383. X      {
  384. X    endlin();
  385. X    return;
  386. X      }
  387. X    oldlin=curlin;        /* remember where we started from */
  388. X    curlin=max(min(curlin+cnt,nxtlin-1),1);    /* move down lines */
  389. X    curchr = *(lines+curlin)+1;    /* point to the current character */
  390. X    change=curlin-oldlin;    /* calculate how many lines changed */
  391. X    update(change);        /* update the screen */
  392. X#ifdef SCR_BUF
  393. X    ttflush();
  394. X#endif
  395. X  }
  396. X
  397. X/* =============================>>> EDIT_RPT <<<============================= */
  398. X  edit_rpt(val)
  399. X  int val;
  400. X  {            /* copy repeat buffer val into buffer for editing */
  401. X
  402. X    SLOW char *cp;
  403. X    SLOW int start_line, old_ef;
  404. X    
  405. X
  406. X    if (!chk_rpt_nr(val))
  407. X    return FALSE;
  408. X
  409. X    old_ef = echof;  echof = FALSE;
  410. X
  411. X    --val;        /* change to relative */
  412. X
  413. X    beglin();        /* start by moving to beginning of current line */
  414. X    start_line = curlin;    /* where we started */
  415. X
  416. X    
  417. X    ins_chr((int)'#'); ins_chr((int)val+'1'); ins_chr((int)':');
  418. X    /* start with number */
  419. X    ins_chr((int)loop_beg);    /* insert start of repeat loop */
  420. X
  421. X    for (cp = &rptbuf[val][0] ; *cp ; ++cp)
  422. X    ins_chr((int)*cp);
  423. X    ins_chr((int)loop_end);
  424. X    ins_chr((int)27); ins_chr((int)27);    /* make a way for store_rpt to find end */
  425. X
  426. X    ins_chr((int)CR);        /* terminate line */
  427. X    curlin = start_line;
  428. X    curchr = *(lines+curlin)+1;
  429. X
  430. X    echof = old_ef;
  431. X
  432. X    verify(1);
  433. X#ifdef SCR_BUF
  434. X    ttflush();
  435. X#endif
  436. X    return (TRUE);
  437. X  }
  438. X
  439. X/* =============================>>> ENDLIN <<<============================= */
  440. X  endlin()
  441. X  { /* endlin - move cursor to end of the line */
  442. X
  443. X    FAST int cnt;
  444. X    SLOW BUFFINDEX i;
  445. X
  446. X    cnt=0;
  447. X    for (i=curchr; *(buff+i)!=ENDLINE; ++i)    /* find end of line */
  448. X    ++cnt;
  449. X    right(cnt);     /* move to end of line */
  450. X#ifdef SCR_BUF
  451. X    ttflush();
  452. X#endif
  453. X  }
  454. X
  455. X/* =============================>>> EXEC_RPT <<<============================= */
  456. X  exec_rpt(knt)
  457. X  int knt;
  458. X  {            /* this is combination of k:r,n& */
  459. X    static char chr;
  460. X    static int val;
  461. X
  462. X    if (! grptch(&chr))        /* get buffer # (k) to use */
  463. X    return (FALSE);
  464. X
  465. X    val = chr - '0';        /* convert to 0 to 9 */
  466. X
  467. X    if (!chk_rpt_nr(val))
  468. X    return FALSE;
  469. X
  470. X    rptuse=val-1;    /* adjust for 0 index int */
  471. X
  472. X    if (knt != 1)
  473. X    echof = FALSE;    /* turn off echo */
  474. X
  475. X    rptcnt[rptuse] = knt > 0 ? knt : (-knt);
  476. X
  477. X    return (TRUE);
  478. X  }
  479. X
  480. X/* =============================>>> FINDDL <<<============================= */
  481. X  finddl(ibeg,cnt)
  482. X  int *ibeg,*cnt;
  483. X  {  /* finddl - find the display line
  484. X    known: current line, calculate where it would go on the screen */
  485. X
  486. X    if (curlin <= dsplin)
  487. X      {             /* it is in first part of the display */
  488. X    *ibeg = 1;
  489. X    *cnt = min(tvlins,nxtlin-1);
  490. X    tvdlin = curlin;        /* update the display line */
  491. X      }
  492. X    else if (nxtlin-curlin <= tvlins-dsplin)    /* at bottom of display */
  493. X      {
  494. X    *ibeg = max(1,nxtlin-tvlins);
  495. X    *cnt = min(tvlins,nxtlin-1);
  496. X    tvdlin=min(curlin,tvlins-(nxtlin-curlin)+1);
  497. X      }
  498. X    else            /* normal case: in middle */
  499. X      {
  500. X    *ibeg=max(1,curlin-dsplin+1);
  501. X    *cnt=min(tvlins,nxtlin-(*ibeg));
  502. X    tvdlin=dsplin;
  503. X      }
  504. X }
  505. X
  506. X/* =============================>>> FINDX  <<<============================= */
  507. X  int findx()
  508. X  {  /* findx - find the x position of the current character
  509. X        handles spacing for tabs, control characters etc */
  510. X
  511. X    SLOW BUFFINDEX i;
  512. X    SLOW int pos,lmold;
  513. X
  514. X    pos = 0;
  515. X    for (i = *(lines+curlin)+1; i<=curchr; ++i)
  516. X    if (*(buff+i-1)<' ' && *(buff+i-1)>0)  /* cur pos depends on last chr */
  517. X        if (*(buff+i-1)==TAB)        /* handle tabs */
  518. X        for (++pos ; ((pos-1) % tabspc)!=0; ++pos)
  519. X            ;
  520. X        else        /* control characters (echoed as ^X) */
  521. X        pos += 2;    /* 2 spaces for other control character */
  522. X    else            /* normal character */
  523. X        ++pos;
  524. X
  525. X    lmold = leftmg;        /* old left margin */
  526. X    for (;;)
  527. X      {
  528. X    if (pos < leftmg)    /* won't fit on screen */
  529. X        leftmg -= 16;    /* shift left */
  530. X    else if (pos >= tvcols+leftmg)
  531. X        leftmg += 16;
  532. X    else
  533. X        break;
  534. X      }
  535. X
  536. X    if (leftmg != lmold)        /* this handles screen shift */
  537. X    newscr();
  538. X
  539. X    return (pos-leftmg+1);
  540. X  }
  541. X
  542. X/* =============================>>> FIXEND  <<<============================= */
  543. X  fixend()
  544. X  { /* fixend - fix the error message line */
  545. X
  546. X    SLOW int lastl;
  547. X
  548. X    lastl = curlin+(tvlins-tvdlin);    /* the last line on the display */
  549. X    tvxy(1,tvhardlines);         /* get to last line */
  550. X    tvelin();
  551. X    if (lastl < nxtlin && tvlins == tvhardlines)  /* only if really there */
  552. X    tvtype(lastl,1);        /* write it out */
  553. X    if (curlin >= 1)
  554. X    tvhdln();            /* restore cursor */
  555. X    else
  556. X    tvxy(1,1);
  557. X#ifdef SCR_BUF
  558. X    ttflush();
  559. X#endif
  560. X   }
  561. X
  562. X/* =============================>>> FOLDCASE <<<============================= */
  563. X  foldcase(cnt)
  564. X  int cnt;
  565. X  {
  566. X    /* fold from upper to lower or lower to upper case if letter */
  567. X    SLOW int ni;
  568. X    SLOW char fchr;
  569. X
  570. X    for (ni = 0 ; ni < cnt ; ++ni)
  571. X      {
  572. X    fchr = *(buff+curchr);    /* get current character */
  573. X    if (fchr >= 'a' && fchr <= 'z')
  574. X        fchr = cupper(fchr);
  575. X    else if (fchr >= 'A' && fchr <= 'Z')
  576. X        fchr = clower(fchr);
  577. X    if (fchr == ENDLINE)
  578. X        right(1);
  579. X    else
  580. X      {
  581. X        delnxt(1);            /* delete cur character */
  582. X        insert((int)fchr,FALSE); /* and put back */
  583. X      }
  584. X      }
  585. X  }
  586. X
  587. X/* =============================>>> GBGCOL <<<============================= */
  588. X  int gbgcol()
  589. X  { /* gbgcol - retrieve unused space in buff */
  590. X
  591. X    FAST int i;
  592. X    SLOW int lastln;
  593. X    SLOW BUFFINDEX nxtbad, nxtgud, to, from, whfrom, offset, newlin;
  594. X
  595. X    tverrb("Compacting buffer ");    /* let the user know, it might take a while */
  596. X    offset = curchr - *(lines+curlin);    /* need to reset curchr later */
  597. X
  598. X    for (nxtbad=1 ; *(buff+nxtbad) != GARBAGE && nxtbad < nxtchr; ++nxtbad)
  599. X        ;        /* find first space to free */
  600. X    nxtgud=nxtbad;
  601. X    lastln = 1;     /* where to start search */
  602. X    do
  603. X      {
  604. X    to=nxtbad;
  605. X    for (from=nxtgud; *(buff+from) == GARBAGE && from<nxtchr; ++from)
  606. X        ;            /* find the next non-garbage character */
  607. X
  608. X/*  nxtbad pts to first junk character,
  609. X    nxtgud pts to next possibly good character */
  610. X
  611. X    if (from >= nxtchr)
  612. X        break;        /* at the end of the buffer */
  613. X    whfrom=from;        /* where it came from */
  614. X    newlin = to;        /* remember start */
  615. X    do
  616. X      {
  617. X        *(buff+to) = *(buff+from++);    /* copy good stuff up */
  618. X      }
  619. X    while (*(buff+to++) != ENDLINE);
  620. X
  621. X    nxtbad = to ; nxtgud = from;
  622. X
  623. X/*  now find the old line
  624. X    following algorithm assumes next line is likely to
  625. X    be near the previous line */
  626. X
  627. X    for (i=lastln ; i<nxtlin ; ++i)    /* start where last looked */
  628. X        if (*(lines+i)==whfrom)
  629. X          {
  630. X        *(lines+i)=newlin;    /* point to new position */
  631. X        if (curlin==i)
  632. X            curchr=newlin+offset;    /* fix curchr if need be */
  633. X        break;
  634. X          }
  635. X
  636. X    if (i >= nxtlin)    /* not found in second half */
  637. X      {
  638. X        for (i=1 ; i < lastln ; ++i)
  639. X        if (*(lines+i)==whfrom)
  640. X          {
  641. X            *(lines+i)=newlin;        /* point to new position */
  642. X            if (curlin==i)
  643. X            curchr=newlin+offset;    /* fix curchr if need be */
  644. X            break;
  645. X          }
  646. X        if (i >= lastln)        /* make sure we really found it */
  647. X          {
  648. X        tverrb("Compactor lost. Quit NOW! ");
  649. X        for (i=1 ; i < 32000 ; ++i)
  650. X            ;
  651. X        return (FALSE);
  652. X          }
  653. X      }
  654. X    lastln = i;            /* start at next line down */
  655. X      }
  656. X    while (nxtgud < nxtchr);
  657. X
  658. X    for (to=nxtbad ; to<=nxtchr ; )
  659. X    *(buff+to++) = GARBAGE;
  660. X
  661. X    nxtchr=nxtbad;            /* update the next free character */
  662. X    tverr("Compactor done");
  663. X    return (nxtsav-nxtchr >= 50);
  664. X }
  665. X
  666. X/* =============================>>> GETSAV <<<============================= */
  667. X  int getsav()
  668. X  { /* ## getsav - get text from save buffer */
  669. X
  670. X    FAST int to,from;
  671. X    SLOW BUFFINDEX fromch;
  672. X    SLOW int newlin;
  673. X
  674. X    if (mxbuff-nxtsav+savlin >= nxtsav-nxtchr)    /* g.c. */
  675. X    if (!gbgcol())
  676. X      {
  677. X        tverrb("No get room ");
  678. X        return (FALSE);
  679. X      }
  680. X
  681. X    if (nxtsav==mxbuff)        /* nothing to save */
  682. X      {
  683. X    return (TRUE);
  684. X      }
  685. X
  686. X    if (mxbuff-nxtsav+savlin >= nxtsav-nxtchr || mxline-nxtlin <= savlin)
  687. X      {             /* room to get save buffer? */
  688. X    tverrb("No get room ");
  689. X    return (FALSE);        /* no room to save */
  690. X      }
  691. X
  692. X/* check if in middle of line */
  693. X    if (curchr > lines[curlin]+1)
  694. X    ins_chr((int)CR);
  695. X
  696. X/*   # move down line to make space for new */
  697. X    from=nxtlin-1;
  698. X    nxtlin=nxtlin+savlin;
  699. X    to=nxtlin-1;
  700. X    while (from >= curlin)    /* copy line ptrs down right amnt. */
  701. X    *(lines+(to--)) = *(lines+(from--));
  702. X
  703. X    newlin=curlin;        /* will insert new lines here */
  704. X    curlin=to+1;
  705. X    fromch = mxbuff;        /* where taking saved stuff from */
  706. X    for ( ; newlin < curlin; ++newlin)
  707. X      {
  708. X    *(buff+nxtchr) = BEGLINE; /* insert begline character */
  709. X    *(lines+newlin) = nxtchr++; /* update line ptrs to new line */
  710. X    do            /* copy stuff from save buffer */
  711. X      {
  712. X        *(buff+nxtchr++) = *(buff+fromch);
  713. X      }
  714. X    while (*(buff+fromch--)!=ENDLINE);
  715. X      }
  716. X    oldlen=0;
  717. X    savlen=savlin;
  718. X    newscr();
  719. X    return (TRUE);
  720. X  }
  721. X
  722. X/* =============================>>> GRPTCH <<<============================= */
  723. X  int grptch(chr)
  724. X  char *chr;
  725. X  { /* grptch - gets a char from repeat buffer or gkbd */
  726. X
  727. X    SLOW char tmpchr;
  728. X
  729. X    if (rptcnt[rptuse]>0)    /* need to fetch from repeat buffer */
  730. X      {
  731. X    if ((*chr=rptbuf[rptuse][nxtrpt[rptuse]]) == 0)
  732. X        return (FALSE);
  733. X    ++nxtrpt[rptuse];
  734. X      }
  735. X    else
  736. X      {
  737. X    gkbd(&tmpchr);    /* read the character from the keyboard */
  738. X    *chr=tmpchr;
  739. X      }
  740. X    return (TRUE);
  741. X  }
  742. X
  743. X/* =============================>>> ins_pat  <<<============================= */
  744. X  ins_pat(lexcnt)
  745. X  int lexcnt;
  746. X  {
  747. X    SLOW char *chrp;
  748. X
  749. X    if (!*pat_buff)
  750. X    return (FALSE);
  751. X    for (chrp = pat_buff ; *chrp ; )    /* simply insert pattern buffer */
  752. X      {
  753. X    if (!ins_chr((int)*chrp++))    /* make sure it works */
  754. X        return (FALSE);
  755. X      }
  756. X
  757. X    return (TRUE); 
  758. X  }
  759. X
  760. X/* =============================>>> save_pat  <<<============================= */
  761. X  save_pat()
  762. X  {  /* save the find pattern, based on oldlen */
  763. X
  764. X    SLOW int i;
  765. X    SLOW char *chrp;
  766. X
  767. X    
  768. X    if (oldlen <= 0)
  769. X      {
  770. X    pat_buff[0] = 0;
  771. X    return;                /* nothing to save */
  772. X      }
  773. X
  774. X    for (i = 1 ; i <= oldlen ; ++i)    /* first, move left */
  775. X      {
  776. X    --curchr;
  777. X    if (*(buff+curchr) == BEGLINE)
  778. X      {
  779. X        if (curlin > 1)
  780. X          {
  781. X        --curlin;
  782. X        for (curchr = *(lines+curlin) ; *(buff+curchr)!=ENDLINE ;
  783. X          ++curchr)
  784. X            ;        /* bump curchr to end of the line */
  785. X          }
  786. X        else
  787. X          {
  788. X        ++curchr;
  789. X        break;
  790. X          }
  791. X      }
  792. X      }
  793. X
  794. X     /* now save, go back right */
  795. X
  796. X    chrp = pat_buff;            /* put in pattern buffer */
  797. X
  798. X    for (i = 1 ; i <= oldlen ; ++i)
  799. X      {
  800. X    if (*(buff+curchr)==ENDLINE)
  801. X      {
  802. X        if (curlin+1 >= nxtlin)
  803. X        break;        /* don't go beyond end! */
  804. X        ++curlin;
  805. X        curchr = *(lines+curlin)+1;
  806. X        *chrp++ = CR;    /* make a cr */
  807. X      }
  808. X    else
  809. X      {
  810. X        if ((chrp - 100) < pat_buff)    /* make sure enough room */
  811. X        *chrp++ = *(buff+curchr);
  812. X        ++curchr;
  813. X      }
  814. X      }
  815. X    *chrp = 0;                    /* terminate */
  816. X  }
  817. X
  818. X/* =============================>>> INSET <<<============================= */
  819. X  inset(val,set)
  820. X  int val,*set;
  821. X  {
  822. X     /* return true if val is in set set */
  823. X
  824. X    while (*set)
  825. X    if (val == *set++)
  826. X        return TRUE;
  827. X    return FALSE;
  828. X  }
  829. X
  830. X/* =============================>>> ins_chr <<<============================= */
  831. X  ins_chr(ival)
  832. X  int ival;
  833. X  {
  834. X    return insert(ival,FALSE);        /* force insert */
  835. X  }
  836. X
  837. X/* =============================>>> INSERT <<<============================= */
  838. X  insert(ival,how)
  839. X  int ival,how;
  840. X  { /* insert - insert a character
  841. X
  842. X    if how is TRUE, then read characters from keyboard until
  843. X    get an escape, otherwise insert ival */
  844. X
  845. X    SLOW BUFFINDEX from,to;
  846. X    SLOW BUFFINDEX curbuf,curend;
  847. X    SLOW int lenins, nocins, ityp, xf;
  848. X    SLOW BUFFINDEX abvchr;
  849. X
  850. X    SLOW char chr;
  851. X
  852. X
  853. X    static int ins_msg = TRUE;    /* own variable */
  854. X
  855. X    if (ins_msg && how)
  856. X    csrins();        /* change cursor */
  857. X
  858. X    if (how)        /* how = 1 regular insert mode */
  859. X      {
  860. X    if (! grptch(&chr))    /* get char using grptch */
  861. X        goto l9999;
  862. X    if (chr == ESC)        /* esc means done */
  863. X      {
  864. X        goto l1000;
  865. X      }
  866. X      }
  867. X    else
  868. X    chr = ival;        /* use the passed value */
  869. X
  870. X    if (chr==ENDLINE || chr==BEGLINE || chr==GARBAGE || (chr==ENDFILE && usecz))
  871. X    goto l9998;        /* don't allow this case! */
  872. X
  873. X    if (curlin < 1)
  874. X      {             /* buffer empty? */
  875. X    curlin=1;        /* init for initial insert */
  876. X    *(lines+1)=nxtchr;
  877. X    curchr=nxtchr+1;
  878. X    *(buff+nxtchr) = BEGLINE;
  879. X    *(buff+nxtchr+1) = ENDLINE;
  880. X    nxtchr += 2;
  881. X    nxtlin = 2;
  882. X      }
  883. X
  884. X    lenins=0;            /* remember length of insert for rmvlst */
  885. X
  886. X    do
  887. X      {
  888. X    if (nxtsav-nxtchr < ALMOSTOUT)
  889. X        if (!gbgcol())
  890. X        goto l9999;    /* collect garbage if necessary */
  891. X    curbuf = *(lines+curlin);  /* pick up the pointer to current line */
  892. X    for (curend=curbuf; *(buff+curend) != ENDLINE; ++curend)
  893. X        ;            /* get line length */
  894. X    if (curend+1 < nxtchr)    /* not using last part of buffer */
  895. X      {
  896. X        if (curend-curbuf >= nxtsav-nxtchr)
  897. X        goto l9998;    /* no more room! */
  898. X        curchr = nxtchr+(curchr-curbuf);    /* where curchr will be */
  899. X        *(lines+curlin) = nxtchr;    /* new line goes here */
  900. X        stcopy(buff,curbuf,buff,&nxtchr); /* copy the line to the end */
  901. X        curend=nxtchr++;    /* reset end pointer */
  902. X        kline(curbuf);    /* kill off the line */
  903. X        curbuf = *(lines+curlin);    /* update beginning pointer */
  904. X      }
  905. X
  906. X/*   #    to here, ready to insert the new character at the end of the line */
  907. X
  908. X    if (chr==' ' && wraplm > 1 && (tvx >= wraplm || leftmg > 1))    /* auto wrap? */
  909. X          chr = CR;
  910. X#ifdef FILELF
  911. X    if (chr == LF && how)
  912. X        ;            /* don't insert lfs in CR/LF systems, echo? */
  913. X    else if (chr == CR)    /* inserting a new line */
  914. X#else
  915. X    if (chr == CR)        /* inserting a new line */
  916. X#endif
  917. X      {
  918. X        if (nxtlin >= mxline)    /* any room? */
  919. X          {
  920. X        tverrb("No more free lines for insert ");
  921. X        goto l9999;
  922. X          }
  923. X
  924. X        for (from=curend; from >= curchr; --from)
  925. X        *(buff+from+2) = *(buff+from);        /* copy chars down */
  926. X        nxtchr += 2;    /* bump nxtchr to free space */
  927. X
  928. X        *(buff+curchr) = ENDLINE;    /* mark as endline */
  929. X        *(buff+curchr+1) = BEGLINE;    /* beginning of line */
  930. X        ++lenins;
  931. X
  932. X        to=nxtlin;        /* move lines down */
  933. X        for (from = nxtlin-1; from > curlin; )
  934. X          {         /* bump the lines down */
  935. X        *(lines+to--) = *(lines+from--);
  936. X          }
  937. X        ++nxtlin;    /* bump to next free line */
  938. X
  939. X        *(lines+curlin+1)=curchr+1;        /* remember where */
  940. X
  941. X        if (ins_msg && how)
  942. X        fixend();                /* fix last line */
  943. X        tvelin();    /* erase stuff after cr */
  944. X
  945. X        nocins = (leftmg > 1);    /* ciline no good if left marg > 1 */
  946. X
  947. X        dwnlin(1);    /* go down one line */
  948. X
  949. X        if (ciline[0] == 0 || nocins)
  950. X          {
  951. X        tvescr();        /* erase the rest of the screen */
  952. X        ityp = min(tvlins-tvdlin+1,nxtlin-curlin);
  953. X          }
  954. X        else
  955. X          {
  956. X        tvinsl();     /* insert a line */
  957. X        ityp = 1;
  958. X          }
  959. X
  960. X        tvtype(curlin,ityp);
  961. X        tvhdln();
  962. X        if (ins_msg && how)
  963. X        csrins();            /* change cursor */
  964. X
  965. X        if (autoin && curlin > 2)        /* automatic indentation! */
  966. X          {
  967. X        ins_msg = FALSE;        /* turn off insert message */
  968. X        abvchr = *(lines+curlin-1)+1;    /* prevous line */
  969. X        while (*(buff+abvchr)==' ' || *(buff+abvchr)==TAB)
  970. X            if (!insert(*(buff+abvchr++),FALSE) )
  971. X              {
  972. X            ins_msg = TRUE;
  973. X            goto l9999;
  974. X              }
  975. X            else if (ttymode)        /* hmm, now what? */
  976. X              {
  977. X            ttymode = FALSE;
  978. X            ttwt(*(buff+abvchr-1));
  979. X#ifdef SCR_BUF
  980. X            ttflush();
  981. X#endif
  982. X            ttymode = TRUE;
  983. X              }
  984. X        ins_msg = TRUE;
  985. X        fixend();
  986. X        csrins();            /* change cursor */
  987. X          }
  988. X      }
  989. X    else if (chr == delkey && how)
  990. X      {
  991. X        if (!delnxt(-1))    /* rubbing out last character */
  992. X        goto l9999;
  993. X        --lenins;
  994. X      }
  995. X    else            /* inserting on the current line */
  996. X      {
  997. X        to = nxtchr;        /* will move to nxtchr */
  998. X        for (from = curend ; from >= curchr; )
  999. X          {
  1000. X        *(buff+to--) = *(buff+from--);
  1001. X          }
  1002. X        curend = nxtchr++;    /* end is now at curchr, bump nxtchr */
  1003. X        *(buff+curchr) = chr; /* stick in the current character */
  1004. X        ++lenins;
  1005. X        if (tvlins < tvhardlines - 10 && how && chr >= ' ')
  1006. X          {
  1007. X        tvelin();
  1008. X        ctrlch(chr);
  1009. X        ctrlch('+');
  1010. X          }
  1011. X        else
  1012. X        tvtyln(curchr);    /* retype rest of the line */
  1013. X        ++curchr;        /* reset the curchr pointer */
  1014. X        xf = findx();
  1015. X        tvxy(xf,tvy);    /* reset the cursor */
  1016. X#ifdef SCR_BUF
  1017. X        ttflush();
  1018. X#endif
  1019. X      }
  1020. X
  1021. X/* the character has been inserted and displayed, get another maybe */
  1022. X
  1023. X    if (how)
  1024. X        if (!grptch(&chr))
  1025. X        goto l9999;
  1026. X      }
  1027. X    while (how && chr != ESC);    /* end of do */
  1028. X
  1029. X    if (tvlins < tvhardlines - 10 && how)    /* fix for slow baud */
  1030. X      {
  1031. X    tvelin();
  1032. X    tvtyln(curchr);    /* retype rest of the line */
  1033. X    xf = findx();
  1034. X    tvxy(xf,tvy);    /* reset the cursor */
  1035. X      }
  1036. X
  1037. X    oldlen = lenins;
  1038. X    savlen = (-1);        /* haven't saved lines */
  1039. X    goto l1000;
  1040. X
  1041. Xl9998:
  1042. X    tverrb("Can't insert that char ");
  1043. Xl9999:
  1044. X    csrcmd();
  1045. X#ifdef SCR_BUF
  1046. X    ttflush();
  1047. X#endif
  1048. X    return FALSE;
  1049. X
  1050. Xl1000:
  1051. X    if (ins_msg && how)
  1052. X    fixend();
  1053. X    csrcmd();
  1054. X#ifdef SCR_BUF
  1055. X    ttflush();
  1056. X#endif
  1057. X    return TRUE;
  1058. X }
  1059. SHAR_EOF
  1060. echo Extracting tvx_defs.ic:
  1061. sed 's/^X//' >tvx_defs.ic <<\SHAR_EOF
  1062. X/*
  1063. X  TVX - A full screen editor written in C
  1064. X
  1065. X   This version of TVX Copyright (c) 1986 by Bruce E. Wampler
  1066. X
  1067. X   Permission is hereby granted for free, unrestricted nonprofit
  1068. X   use of this software.  Please feel free to modify, distribute,
  1069. X   and share this software as long as you aren't making any money
  1070. X   from it.  If you want to use this code in a profit making environment,
  1071. X   please contact the author for permission.
  1072. X
  1073. X  Revison summary:  (edit ALL cases of VERSION when change)
  1074. X      Version
  1075. X    1/10/    - this code first released to USENET
  1076. X    1/29/86  - memory code fixed, changes contained in first fix notice
  1077. X    1/30/86  - fixed insert mode msg problem in unkill
  1078. X    2/6/86   - cleaned up atari stdio.h problem, bug with noteloc
  1079. X    2/11/86  - added required code for Unix System V
  1080. X    2/14/86  - GETSIO option, allows fgets I/O if faster than fgetc
  1081. X    2/17/86  - bug in multi-line repeat loop, bug in addfil: ALMOSTOUT
  1082. X    2/22/86  - vi emulation + modeless version for emacs and tvx0
  1083. X    2/25/86  - added SCR_BUF stuff from decvax!gancarz (Mike Gancarz)
  1084. X    3/6/86  - added hires screen for atari st [released to mod.sources]
  1085. X
  1086. X*********************************************************************  */
  1087. X
  1088. X
  1089. X/* ======================================================================== */
  1090. X/* Define the editor being emulated: (possibly by -D switch to cc)
  1091. X
  1092. X    TVX_EM - The original tvx (this really IS tvx)
  1093. X    VI_EM  - emulates vi
  1094. X    EMAX_EM - emulates emacs
  1095. X    TVX0M_EM - a tvx flavored modeless editor
  1096. X*/
  1097. X
  1098. X/* #define TVX_EM */
  1099. X/* #define VI_EM */        /* vi emulation */
  1100. X/* #define TVX0M_EM */        /* modeless emulation */
  1101. X/* #define EMAX_EM */
  1102. X
  1103. X/* ======================================================================== */
  1104. X/* ====> Select terminal version: #define at most ONE of <================= */
  1105. X/*       the following symbols debending the terminal used. (except SUN)    */
  1106. X
  1107. X#undef IBMPC
  1108. X#undef ATARI520
  1109. X/* #define VT100 */
  1110. X#undef HP2621
  1111. X#define TERMCAP             /* Unix TERMCAP version */
  1112. X/* #define SUN */        /* define for SUN in addition to TERMCAP */
  1113. X
  1114. X
  1115. X/* ======================================================================== */
  1116. X/* ==================> Select ONE operating system  <====================== */
  1117. X
  1118. X/* #define OSCPM */        /* CP/M-80 */
  1119. X#undef MSDOS            /* 8086 MS-DOS */
  1120. X#undef GEMDOS            /* atari 520 gemdos */
  1121. X
  1122. X/* NOTE:  If you define UNIX, please look at the beginning of tvx_unix.c
  1123. X   for additional Unix related options */
  1124. X#define UNIX         /* unix is a bit different! */
  1125. X
  1126. X/* !!!! following defines used in ADDITION to UNIX if used !!!! */
  1127. X/* #define SYSV */    /* define this in ADDITION to UNIX for System V */
  1128. X/* #define ULTRIX11 */    /* for DEC PDP-11 Ultrix */
  1129. X/* #define PRO350 */    /* DEC PRO-350 system */
  1130. X
  1131. X#define SCR_BUF        /* buffered screen update much faster on Unix */
  1132. X    /* not implemented for other systems yet, but should be easy */
  1133. X#define S_BUFSIZE 2048    /* size of screen buffer */
  1134. X
  1135. X/* ======================================================================== */
  1136. X
  1137. X/* the include for stdio.h is here after os has been defined */
  1138. X
  1139. X#ifdef GEMDOS
  1140. X/* GEMDOS requires that the brain damaged stdio.h provided with the
  1141. X   developer's kit be replaced to get rid of conflicts with the
  1142. X   portab.h file - ugly.  A special file called stdiotvx.h is provided
  1143. X   with the atari distribution */
  1144. X
  1145. X#include "stdiotvx.h"
  1146. X
  1147. X#else
  1148. X#include <stdio.h>
  1149. X#endif
  1150. X
  1151. X/* ========> select other options by defining appropriate symbols <======== */
  1152. X
  1153. X#define VB /**/        /* whether or not to create backup log version */
  1154. X
  1155. X#undef ULBD        /* supports underline, bold in ^U, ^B format */
  1156. X
  1157. X#define NEED_MISC_DEFS /**/
  1158. X/* ======================================================================== */
  1159. X#ifdef NEED_MISC_DEFS
  1160. X/* following definitons are usually not defined in most stdio.h's */
  1161. X
  1162. X#define NIL (-1)        /* nil ptr for lists */
  1163. X#define TRUE 1
  1164. X#define FALSE 0
  1165. X
  1166. X/* following might not be defined in some C's stdio.h, but usually are */
  1167. X
  1168. X/* #define EOF (-1) */    /* standard end of file */
  1169. X/* #define EOS '\0' */    /* standard end of string */
  1170. X#endif
  1171. X
  1172. X/* ********************************************************************** */
  1173. X/* ********************************************************************** */
  1174. X
  1175. X/*  Other options now selected automatically depending on above #defines  */
  1176. X
  1177. X/* ********************************************************************** */
  1178. X/* ********************************************************************** */
  1179. X
  1180. X/* ----------------- Emulator Version ----------------------------------- */
  1181. X
  1182. X#ifdef TVX_EM
  1183. X#define TVX_CMDSET            /* command set used by tvx */
  1184. X#define START_IDM "TVX - Full Screen Editor"
  1185. X#define START_HELPM "Press ? for help after starting"
  1186. X#define VERSION " - TVX (3/6/86) - " 
  1187. X#define DEF_CUTMODE 0
  1188. X#endif
  1189. X
  1190. X#ifdef VI_EM
  1191. X#define START_IDM "TVX - Editor emulating vi"
  1192. X#define VERSION " - VIX (3/6/86) - " 
  1193. X#define START_HELPM "Press = for help after starting"
  1194. X#define DEF_CUTMODE 1
  1195. X
  1196. X#undef VI_MODS        
  1197. X/* VI_MODS defines some "extensions" or enhancements to vi that
  1198. X   the local users prefer to the way vi does things.  Specifically:
  1199. X   1) j and k become line oriented rather than column oriented. ^P behaves
  1200. X   in the usual up column, and ^N work like the usual down arrow.
  1201. X   2) r is changed to advance the cursor after the changed char.
  1202. X*/
  1203. X#endif
  1204. X
  1205. X#ifdef EMAX_EM
  1206. X#define NOMODE_LEX
  1207. X#define START_IDM "EMAX - TVX/EMAX Full Screen Editor"
  1208. X#define START_HELPM "Press <ESC>? for help after starting"
  1209. X#define VERSION " - EMAX (3/6/86) - " 
  1210. X#define DEF_CUTMODE 1
  1211. X#endif
  1212. X
  1213. X#ifdef TVX0M_EM
  1214. X#define TVX_CMDSET
  1215. X#define NOMODE_LEX
  1216. X#define START_IDM "Modeless TVX - Full Screen Editor"
  1217. X#define START_HELPM "Press <ESC>? for help after starting"
  1218. X#define VERSION " - TVX/0 (3/6/86) - " 
  1219. X#define DEF_CUTMODE 0
  1220. X#endif
  1221. X
  1222. X/* ---------------- Operating System dependent defintions --------------- */
  1223. X
  1224. X/* important note: max value for REPEATBUFS is 9!               */
  1225. X
  1226. X/* ---------------------------------------------------------------------- */
  1227. X#ifdef OSCPM            /* uses Software Toolworks C/80 */
  1228. X#define BACKUPNAME "BACKUP.LOG"    /* backup log file name */
  1229. X#define BUFFLIMIT 2500        /* how much empty space to save in buffer */
  1230. X#define FILEREAD "rb"        /* read a file in binary */
  1231. X#define FILEWRITE "wb"        /* write a binary file */
  1232. X#define FNAMESIZE 14        /* size of file names */
  1233. X#define INT16 /**/        /* ints are 16 bits */
  1234. X#define LINELIMIT 75        /* number of spare lines to save */
  1235. X#define MAKE_BACKUP 1        /* 1 (true), want to make .bak file by default */
  1236. X#define MAXBUFF 40000        /* maximum number of total characters */
  1237. X#define MAXLINE 1150        /* maximum number of lines (abt. MAXBUFF/30) */
  1238. X#define REPEATBUFS 3        /* number of repeat buffers allowed */
  1239. X#define USELF /**/        /* using line feed on video */
  1240. X#define FILELF /**/            /* also in files */
  1241. X#define NEWLINE 13        /* 1st line separator: CR */
  1242. X#define USECTRLZ /**/
  1243. X#define NEEDTVLIB /**/        /* need standard c lib routines */
  1244. X#define BUFFINDEX unsigned int
  1245. X#define FAST static
  1246. X#define SLOW static
  1247. X#endif
  1248. X
  1249. X/* ---------------------------------------------------------------------- */
  1250. X#ifdef MSDOS
  1251. X#define HELP /**/        /* help available */
  1252. X#define FULLHELP /**/        /* all of it */
  1253. X#ifdef TVX_EM
  1254. X#define CONFIGFILE /**/        /* allow -c switch */
  1255. X#endif
  1256. X#define BACKUPNAME "BACKUP.LOG"    /* backup log file name */
  1257. X#define BUFFLIMIT 3000        /* how much empty space to save in buffer */
  1258. X#define FILEREAD "rb"        /* read a file in binary */
  1259. X#define FILEWRITE "wb"        /* write a binary file */
  1260. X#define FNAMESIZE 70        /* size of file names, allows paths */
  1261. X#undef GETSIO            /* fgets slower than fgetc for cii-86 */
  1262. X#define INT16 /**/        /* ints are 16 bits */
  1263. X#define LINELIMIT 75        /* number of spare lines to save */
  1264. X#define MAKE_BACKUP 1        /* 1 (true), want to make .bak file by default */
  1265. X#define MAXBUFF 60000        /* maximum number of total characters */
  1266. X#define MAXLINE 3500        /* maximum number of lines (abt. MAXBUFF/30) */
  1267. X#define REPEATBUFS 5        /* number of repeat buffers allowed */
  1268. X#define USELF /**/        /* using line feed */
  1269. X#define FILELF    /**/        /* also in files */
  1270. X#define NEWLINE 13        /* 1st line separator: CR */
  1271. X#define BUFFINDEX unsigned int
  1272. X/* #define USECTRLZ */        /* default value for ^Z */
  1273. X#define FAST static
  1274. X#define SLOW static
  1275. X#endif
  1276. X/* ---------------------------------------------------------------------- */
  1277. X/* ---------------------------------------------------------------------- */
  1278. X#ifdef GEMDOS
  1279. X#define HELP /**/        /* help available */
  1280. X#define FULLHELP /**/        /* all of it */
  1281. X#ifdef TVX_EM
  1282. X#define CONFIGFILE /**/        /* allow -c switch */
  1283. X#endif
  1284. X#define BACKUPNAME "BACKUP.LOG"    /* backup log file name */
  1285. X#define BUFFLIMIT 3000        /* how much empty space to save in buffer */
  1286. X#define FILEREAD "r"        /* read a file in binary */
  1287. X#define FILEWRITE "w"        /* write a binary file */
  1288. X#define fopen fopenb
  1289. X#define FNAMESIZE 70        /* size of file names, allows paths */
  1290. X#define GETSIO            /* use fgets for main file I/O */
  1291. X#define INT16 /**/        /* ints are 16 bits */
  1292. X#define LINELIMIT 75        /* number of spare lines to save */
  1293. X#define MAKE_BACKUP 1        /* 1 (true), want to make .bak file by default */
  1294. X#define MAXBUFF 60000        /* maximum number of total characters */
  1295. X#define MAXLINE 3500        /* maximum number of lines (abt. MAXBUFF/30) */
  1296. X#define REPEATBUFS 5        /* number of repeat buffers allowed */
  1297. X#define USELF /**/        /* using line feed */
  1298. X#define FILELF /**/        /* also in files */
  1299. X#define NEWLINE 13        /* 1st line separator: CR */
  1300. X#define USECTRLZ /**/
  1301. X#define BUFFINDEX long
  1302. X#define FAST register
  1303. X#define SLOW static
  1304. X#endif
  1305. X/* ---------------------------------------------------------------------- */
  1306. X
  1307. X/* ---------------------------------------------------------------------- */
  1308. X#ifdef UNIX
  1309. X#define getchr fgetc
  1310. X#define FLOWCONTROL /**/    /* define this if you want ^S/^Q enabled */
  1311. X#undef COMMA_BAK        /* #define if you want ".," backup files */
  1312. X
  1313. X#define NO_EXTEND_CHAR        /* only allow 127 displayable chars */
  1314. X
  1315. X#define HELP /**/        /* help available */
  1316. X#define FULLHELP /**/        /* all of it */
  1317. X#ifdef TVX_EM
  1318. X#define CONFIGFILE /**/        /* allow -c switch */
  1319. X#endif
  1320. X#define BACKUPNAME "BACKUP.LOG"    /* backup log file name */
  1321. X#define BUFFLIMIT 4000        /* how much empty space to save in buffer */
  1322. X#define FILEREAD "r"        /* read a file in binary */
  1323. X#define FILEWRITE "w"        /* write a binary file */
  1324. X#define FNAMESIZE 80        /* size of file names, allows paths */
  1325. X#define GETSIO            /* use fgets for main file I/O */
  1326. X#define LINELIMIT 100        /* number of spare lines to save */
  1327. X#define MAKE_BACKUP 1        /* 1 (true), want to make .B file by default */
  1328. X        /* change to 0 if don't want, which is like other Unix eds */
  1329. X#define MAXBUFF 120000        /* maximum number of total characters */
  1330. X#define MAXLINE 5000        /* maximum number of lines (abt. MAXBUFF/30) */
  1331. X#define NEWLINE 10
  1332. X#define REPEATBUFS 9        /* number of repeat buffers allowed */
  1333. X#define USELF /**/        /* using line feed on screen */
  1334. X#define BUFFINDEX unsigned int
  1335. X#define FAST register
  1336. X#define SLOW             /* dynamics */
  1337. X#endif
  1338. X
  1339. X/* ---------------------------------------------------------------------- */
  1340. X
  1341. X#ifdef ULTRIX11
  1342. X#undef MAXBUFF
  1343. X#undef MAXLINE
  1344. X#define MAXBUFF 40000        /* maximum number of total characters */
  1345. X#define MAXLINE 1150        /* maximum number of lines (abt. MAXBUFF/30) */
  1346. X#endif
  1347. X
  1348. X/* ---------------------------------------------------------------------- */
  1349. X/* ---------------------- Misc defintions ------------------------------- */
  1350. X
  1351. X#define ARB 100
  1352. X#define ALMOSTOUT 300   /* garbage collect when ALMOSTOUT characters left */
  1353. X#define BACKSPACE 8
  1354. X#define BELL 7       /* bell */
  1355. X#define CR 13 
  1356. X#define ESC 27 
  1357. X#define ENDFILE 26
  1358. X#define LF 10 
  1359. X#define NO 0
  1360. X#define TOGUNDERLINE 21     /* ^U for underline */
  1361. X#define TOGBOLD 2         /* ^B for bold */
  1362. X#define TAB 9
  1363. X#define YES 1
  1364. X/* these look like they can be changed, but beware, especially
  1365. X   with positive values (you can't change ENDLINE to LF, for example) */
  1366. X#define BEGLINE (char)(0xff)
  1367. X#define ENDLINE 0          /* marks end of a line */
  1368. X#define GARBAGE (char)(0xfe)  /* filler character for gbgcol */
  1369. X
  1370. X#define E0 0            /* element 0 of arrays (skipped) */
  1371. X
  1372. X/* ---------------------- Wild card values ----------------------------------- */
  1373. X#define W_letter 12        /* ^L is letter */
  1374. X#define W_digit 4        /* ^D is digit */
  1375. X#define W_alpha 1        /* ^A is alpha num */
  1376. X#define W_punc 16        /* ^P is punctuation */
  1377. X#define W_anything 24        /* ^X is any character */
  1378. X#define W_others 15        /* ^O is non-alpha */
  1379. X#define W_user 21        /* ^U is user set */
  1380. X#define W_span 23        /* ^W is "word" of */
  1381. X#define W_skip 14        /* ^N is not in word of*/
  1382. X/* -------------------- Command Definitions ----------------------------- */
  1383. X
  1384. X#ifdef TVX_CMDSET        /* both 2 mode and modeless tvx use the same */
  1385. X#define VRIGHT 1        /* lex val right, or foward one character */
  1386. X#define VLEFT 2         /* left or backwards one character */
  1387. X#define VDOWNLINE 3        /* down line, to beg. of next line */
  1388. X#define VUPLINE 4        /* up line, to beg. of prev. line */
  1389. X#define VDOWNCOL 5        /* down in column ^D */
  1390. X#define VUPCOL 6        /* up in column ^U */
  1391. X#define VDELLAST 7        /* delete previous character */
  1392. X#define VDELNEXT 8        /* delete forward */
  1393. X#define VINSERT 9        /* insert text */
  1394. X#define VKILLALL 10        /* kill entire current line */
  1395. X#define VKILLREST 11        /* kill rest of current line */
  1396. X#define VKILLPREV 12        /* kill previous part of line */
  1397. X#define VBEGLINE 13        /* beginning of current line */
  1398. X#define VENDLINE 14        /* back of current line */
  1399. X#define VSEARCH 15        /* find a string */
  1400. X#define VNEXT 16        /* next - search across pages */
  1401. X#define VFLIP 17        /* page a screen full */
  1402. X#define VTOP 18            /* top of buffer */
  1403. X#define VBOTTOM 19        /* bottom of buffer */
  1404. X#define VFBEGIN 20        /* beginning of file */
  1405. X#define VVERIFY 21        /* verify: rewrite screen or show dot */
  1406. X#define VOPENLINE 22        /* open a new line */
  1407. X#define VREMOVE 23        /* remove last thing maniuplated */
  1408. X#define VSAVE 24        /* put text in save buffer */
  1409. X#define VGET 25            /* get or restore save buffer */
  1410. X#define VWPAGE 26        /* write current page, fetch next page */
  1411. X#define VYANK 27        /* "save" from external file */
  1412. X#define VQUIT 28        /* quit */
  1413. X#define VSAGAIN 29        /* search for the thing again */
  1414. X#define VXREPEAT 30        /* execute repeat buffer */
  1415. X#define VMEMORY 31        /* print remaining buffer space */
  1416. X#define VSETPARS 32        /* set parameters */
  1417. X#define VRMVINS 33        /* remove last, enter insert mode */
  1418. X#define VUNKILL 34        /* unkill last line killed */
  1419. X#define VMVWORD 35        /* move over a word at a time */
  1420. X#define VMVBWORD 36        /* move over words backwards */
  1421. X#define VSAPPEND 37        /* append to save buffer */
  1422. X#define VPRINTS 38        /* print screen */
  1423. X#define VHELP 39        /* show contents of repeat buffer */
  1424. X#define VHALFP 40        /* half a page down */
  1425. X#define VABORT 41        /* abort */
  1426. X#define VCHANGE 42        /* change n chars */
  1427. X#define VJUMP 43        /* jump back to prev loc */
  1428. X#define VTIDY 44        /* tidy - justify */
  1429. X#define VNOTELOC 45        /* note current location */
  1430. X#define VRETNOTE 46        /* ^N  - Return to noted loc */
  1431. X#define VSYSTEM 47        /* call operating system */
  1432. X#define VEDITRPT 48        /* edit repeat buffer n */
  1433. X#define VSTORERPT 49        /* store in repeat buffer n */
  1434. X#define VEXECRPT 50        /* execute repeat buffer k n time */
  1435. X#define VINSPAT 51        /* insert search pattern */
  1436. X#define VUSER1 52        /* spare 1 */
  1437. X#define VUSER2 53        /* spare 2 */
  1438. X#define VFOLDCASE 54        /* fold case */
  1439. X#define LEXVALUES 54        /* total number of lexical values */
  1440. X#endif
  1441. X
  1442. X#ifdef VI_EM            /* needed vi_em lexical values */
  1443. X#define VMEMORY 4
  1444. X#define VHELP 7
  1445. X#define VSEARCH 12
  1446. X#define VRSEARCH 15
  1447. X#define VDOWNCOL 23
  1448. X#define VUPCOL 24
  1449. X#define VSAPPEND 32
  1450. X#define VENDZ 33
  1451. X#define VMVBWORD 36
  1452. X#define VRSAGAIN 27
  1453. X#define VPUT 29
  1454. X#define VTVX 30
  1455. X#define VSAPPEND 32
  1456. X#define VENDZ 33
  1457. X#define VMVBWORD 36
  1458. X#define VINSERT 40
  1459. X#define VNOTELOC 44
  1460. X#define VSAGAIN 45
  1461. X#define VGET 47
  1462. X#define VMVWORD 51
  1463. X#define VSAVE 53
  1464. X#define VNOOP 50
  1465. X
  1466. X#define LEXVALUES 54        /* total number of lexical values */
  1467. X#endif
  1468. X
  1469. X#ifdef EMAX_EM
  1470. X#define VSAVE 100
  1471. X#define VSAPPEND 101
  1472. X#define VNEXT 102
  1473. X#define VSAGAIN 103
  1474. X#define VTVX 3
  1475. X#define VNOOP 7
  1476. X#define VDOWNCOL 11
  1477. X#define VUPCOL 13
  1478. X#define VOPENLINE 12
  1479. X#define VRSEARCH 14
  1480. X#define VSEARCH 15
  1481. X#define VGET 18
  1482. X#define VEXTEND 17
  1483. X#define VQUIT 19
  1484. X#define VMVBWORD 24
  1485. X#define VMVWORD 25
  1486. X#define VHELP 27
  1487. X
  1488. X#define LEXVALUES 27
  1489. X#endif
  1490. X
  1491. X#define UNKNOWN (-5)        /* unknown lexical value */
  1492. X
  1493. X/* ********************************************************************* */
  1494. SHAR_EOF
  1495. echo ALL DONE!
  1496. exit 0
  1497.  
  1498.